<template>
    <div class="header" :style="{background: bgColor}">
        <i v-if="showBack" @click="goBack" class="el-icon-arrow-left"></i>
        <p>{{headerTxt}}</p> 
    </div>
</template>

<script>
export default {
    props: {
        headerTxt: {
            type: String,
            default: ''
        },
        bgColor: {
            type: String,
            default: '#0F1117'
        },
        showBack: {
            type: Boolean,
            default: false
        }
    },
    data () {
        return {
            
        }
    },
    methods:{
        goBack () {
            let url = window.location.href;
            if(url.indexOf('/register') != -1){
                this.$router.push({
                    path: '/login'
                })
            }else{
                this.$router.back();
            }
        }
    }
}
</script>

<style lang="stylus" scoped>
    .header{
        margin: 0;
        padding: 0;
        width: 100%;
        height: 1.1rem;
        position: fixed;
        z-index: 99;
        top: 0;
        left: 0;
        p{
            margin: 0;
            line-height: 1.1rem;
            text-align: center;
            font-size: .36rem;
            color: #fff;
        }
        i{
            color: white;
            position: absolute;
            left: .3rem;
            font-size: .42rem;
            margin-top: .37rem;
            color: #fff;
            // display: inline-block;
            // width  :1rem;
            // line-height :1rem;
            // height: 1rem;
        }
    }
</style>

